package cn.itsource.ymcc.web.controller;

import cn.itsource.ymcc.result.JsonResult;
import cn.itsource.ymcc.service.IVerifyService;
import cn.itsource.ymcc.vo.RegisterSmsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/common")
public class VerifyController {
    @Autowired
    private IVerifyService iVerifyService;

    /**
     * 返回图形验证码
     *  编码后的格式
     * @param imageCodeKey
     * @return
     */
    @GetMapping("/verifycode/imageCode/{imageCodeKey}")
    public JsonResult verifyCode(@PathVariable("imageCodeKey")String imageCodeKey){

        return iVerifyService.verifyCode(imageCodeKey);
    }

    /**
     * 获取手机验证码
     * @param registerSmsVo
     * @return
     */
    @PostMapping("/verifycode/sendSmsCode")
    public JsonResult sendSmsCode(@RequestBody @Valid RegisterSmsVo registerSmsVo){

        return iVerifyService.sendSmsCode(registerSmsVo);
    }
}
